﻿using System.ComponentModel.DataAnnotations;
using ServiceStack.DataAnnotations;

namespace NetSurveillance.WebApp.DataServices.Models
{
    [Alias("WebAppUserMenus")]
    public class UserMenu : BaseModel
    {
        [AutoIncrement]
        public long Id { get; set; }

        [References(typeof(User))]
        public long UserId { get; set; }

        [References(typeof(Menu))]
        public long MenuId { get; set; }

        /// <summary>
        /// 这个字段存储权限之和，需要判断一个操作是否具有权限只需要取该权限与做与操作，大于0表示有权限,等于0表示无权限
        /// </summary>
        [Required]
        [Default(typeof(int), "0")]
        public PermissionType Permission { get; set; }

        [Ignore]
        public User User { get; set; }

        [Ignore]
        public Menu Menu { get; set; }
    }
}